import React, { PureComponent } from 'react';
import { Button } from 'antd-mobile';

import testPaperImg from '@/assets/images/im_test_examination.png';
import styles from './index.less';
interface OwnerProps {

  type?: 1 | 2 | 3 | 4;  // 1模拟练习2:模拟考试3:正式考试 4:预约考试
  onOK?: () => void;  // 开始
}
class Index extends PureComponent<OwnerProps, any> {
  state = {
    hasHistory: false
  }
  componentDidMount() {
    const {
      type
    } = this.props;
    const examState = localStorage.getItem('examState');
    if (examState) {
      const data = JSON.parse(examState)
      if (data && data.type === type) {
        this.setState({ hasHistory: true })
      }
    }
  }
  onOK = () => {
    const {
      onOK
    }=this.props
    if(onOK && typeof onOK==='function' ){
      onOK()
    }
  }
  render() {

    return (
      <div className={styles.start}>
        <div className={styles.test_paper}>
          <img alt="" src={testPaperImg} className={styles.test_paper_img} />
        </div>
        <div>

          <div className={styles.button_wrap} >
            <Button onClick={this.onOK} className={styles.back} type="primary">{this.state.hasHistory ? '继续考试' : '开始'}</Button>
          </div>
        </div>




      </div>
    )
  }
}

export default Index;

